package guiElement

import (
	"MetroBuilderGameJam/gameEngine/geom"
	"image/color"
)

func NewButton(purpose Purpose, text string, p geom.Point, s geom.Size, isActive func() bool, onClick func()) *Button {
	return &Button{
		position: p,
		size:     s,
		text:     text,
		click:    onClick,
		isActive: isActive,
		Purpose:  purpose,
	}
}

type Button struct {
	position  geom.Point
	size      geom.Size
	color     color.Color
	text      string
	isActive  func() bool
	click     func()
	IsPressed bool
	Purpose   Purpose
}

func (b *Button) Position() geom.Point {
	return b.position
}
func (b *Button) Size() geom.Size {
	return b.size
}
func (b *Button) GetPurpose() Purpose {
	return b.Purpose
}
func (b *Button) GetText() string {
	return b.text
}

func (b *Button) IsActive() bool {
	return b.isActive()
}

func (b *Button) Click() {
	if b.click != nil {
		b.click()
	}
}

func (b *Button) SetText(text string) {
	b.text = text
}

func (b *Button) SetSize(size geom.Size) {
	b.size = size
}

func (b *Button) GetColor() color.Color {
	return b.color
}

func (b *Button) SetColor(color color.Color) {
	b.color = color
}
